package com.turman.plyopengl.programs

import android.content.Context
import android.opengl.GLES20
import androidx.compose.ui.graphics.Color
import com.turman.plyopengl.R

class ColorShaderProgram(context: Context) :
    ShaderProgram(context, R.raw.simple_vertex_shader2, R.raw.simple_fragment_shader2) {
    private val uMatrixLocation: Int = getUniformLocation(U_MATRIX)
    val aPositionLocation: Int = getAttribLocation(A_POSITION)
    val uColorLocation: Int = getAttribLocation(U_COLOR)

    fun setUniforms(matrix: FloatArray, color: Color) {
        GLES20.glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0)
        GLES20.glUniform4f(uColorLocation, color.red, color.green, color.blue, color.alpha)
    }

    companion object {
        private const val U_MATRIX = "u_Matrix"

        private const val A_POSITION = "a_Position"
        private const val U_COLOR = "u_Color"
        private const val POINT_SIZE = "point_Size"
    }
}